package com.sky.mapper;

import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {
    /**
     * 根据菜品id查询套餐
     *
     * @param ids
     * @return
     */
    List<Long> getSetmealByDishIds(List<Long> ids);

    /**
     * 根据菜品id获取其的套餐id
     * @param id
     * @return
     */
    List<Long> getByDishId(Long id);

    /**
     * 保存套餐和菜品的关联
     * @param dishes
     */
    void insertDishBySetmeal(List<SetmealDish> dishes);

    /**
     * 根据套餐id删除与菜品表的关联-批量版
     * @param id
     */
    @Delete("delete from setmeal_dish where setmeal_id = #{id};")
    void deleteBySetmealId(Long id);

    /**
     * 查询套餐与菜品的关联
     * @param id
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<SetmealDish> getDishBySetmealId(Long id);
}
